function [PL] = PropagationModel(d, tagcen, readercen, i, tipo, n)

%       PL(d) = 10nlog(d/d0) + Sum(WAF)    
%       n = 1.8 se Free Space ou n = 3 se ambientes complicados

error = 1;
partition = 2;
wall = 5;

if (tipo == 0)  % ---- Divisorias e Obstaculos ---

    if (tagcen(i,4) == 4)

        if (i == 8)  
            PL = 10 * n * log10(d) +  2 * partition + rand(1,1);
        else
            PL = 10 * n * log10(d) + rand(1,1);   
        end
   else
            %n = 3.0;
            PL = 10 * n * log10(d) + 2 * wall + rand(1,1);     
    end

end


if (tipo == 1) % ---- Falha nas etiquetas ---
    
    if (tagcen(i,4) == 4)
        if (i == 8) 
            PL = 10 * n * log10(d) + error * rand(1,1);
        else
            PL = 10 * n * log10(d) +  rand(1,1);
        end
    else
            %n = 3.0;
            PL = 10 * n * log10(d) + 2 * wall + rand(1,1);         
    end
end

if (tipo == 2) % ---- Objetos Reflexivos ---
    
    if (tagcen(i,4) == 4)
        if (i == 8) || (i == 9)
            PL = 10 * n * log10(d) + error * rand(1,1);
        else
            PL = 10 * n * log10(d) +  rand(1,1);
        end
    else
            %n = 3.0;
            PL = 10 * n * log10(d) + 2 * wall + rand(1,1);              
    end
end

if (tipo == 3) % ---- Interferencias ---
    
    if (tagcen(i,4) == 4)
        if (i == 13) 
            PL = 10 * n * log10(d) + error * rand(1,1);
        else
            PL = 10 * n * log10(d) +  rand(1,1);
        end
    else
            %n = 3.0;
            PL = 10 * n * log10(d) + 2 * wall + rand(1,1);         
    end
end

if (tipo == 4) % ---- Tracking ---
    
    if (readercen(1,4) == 4)
        PL = 10 * n * log10(d) + rand(1,1);
        else
            %n = 3.0;
            PL = 10 * n * log10(d) + 2 * wall + rand(1,1);         
    end
end